<style>
    .layui-form-item .layui-input-company {width: auto;padding-right: 10px;line-height: 38px;}
</style>
<div class="layuimini-container layuimini-page-anim">
    <div class="layuimini-main">

        <div class="layui-form layuimini-form">
			
            <div class="layui-form-item">
                <label class="layui-form-label required">收件箱</label>
                <div class="layui-input-block">
                    <input type="text" name="email_addr" lay-verify="required" lay-reqtext="请输入收件邮箱" placeholder="请输入收件邮箱"  value="" class="layui-input">
                    <tip>填写邮箱</tip>
                </div>
            </div>
			
              <div class="layui-form-item">
                <label class="layui-form-label required">标题</label>
                <div class="layui-input-block">
                    <input type="text" name="email_title" lay-verify="required" lay-reqtext="请输入邮箱标题" placeholder="请输入邮箱标题"  value="" class="layui-input">
                    <tip>填写邮件标题</tip>
                </div>
            </div>
			<div class="layui-form-item">
                <label class="layui-form-label required">内容</label>
                <div class="layui-input-block">
                    <textarea name="email_content" placeholder="请输入邮箱内容" class="layui-textarea"></textarea>
                </div>
            </div>
			
			
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="setting">发送</button>
				</div>
				 
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form','miniPage'], function () {
        var form = layui.form
            , layer = layui.layer;
		$ = layui.$;
		miniPage = layui.miniPage;
        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();

        //监听提交
        form.on('submit(setting)', function (data) {
            /*parent.layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            });*/
			//开启
			var indexLoad = layer.load(2, {shade: false});
			
			var url = "/admin/emailTest"
            $.post(url,data.field,function(resp){
				//关闭
				layer.close(indexLoad);
				
				if(resp.code == 0){
					//成功
					layer.msg("已发送",{end:function(){
						location.reload();
						// 关闭弹出层
						// layer.closeAll();
					}});
					
				}else{
					layer.msg(resp.msg);
				}
				
		    },"json");
			
            return false;
        });

    });
</script>